bitkeeper revision 1.596.1.2 (3fb36386_diWp9iTBJCjk8zK8bRIEw)
authorsmh22@labyrinth.cl.cam.ac.uk <smh22@labyrinth.cl.cam.ac.uk>
Thu, 13 Nov 2003 10:57:10 +0000 (10:57 +0000)
committersmh22@labyrinth.cl.cam.ac.uk <smh22@labyrinth.cl.cam.ac.uk>
Thu, 13 Nov 2003 10:57:10 +0000 (10:57 +0000)
tweaks

xenolinux-2.4.22-sparse/arch/xeno/drivers/block/xl_block.c

index 14c14053e01fdc0da23e2ae700a04e92b97996fe..23f445515c83c1714ff77d873a7bc3a418d6a021 100644 (file)
@@ -69,10 +69,23 @@ int xenolinux_block_open(struct inode *inode, struct file *filep)
     short xldev = inode->i_rdev; 
     struct gendisk *gd = xldev_to_gendisk(xldev);
     xl_disk_t *disk = xldev_to_xldisk(inode->i_rdev);
+    short minor = MINOR(xldev); 
+
+    if(!gd->part[minor].nr_sects) { 
+       /* Device either doesn't exist, or has zero capacity; we use 
+          a few cheesy heuristics to return the relevant error code */
+       if(disk->capacity || (minor & (gd->max_p - 1))) { 
+           // we have a real device, but no such partition, or we just 
+           // have a partition number so guess this is the problem 
+           return -ENXIO;     // no such device or address 
+       } else if (gd->flags[minor >> gd->minor_shift] & GENHD_FL_REMOVABLE) {
+           // this is a removable device => assume that media is missing 
+           return -ENOMEDIUM; // media not present (this is a guess) 
+       } else 
+           // just go for the general 'no such device' error
+           return -ENODEV;    // no such device
+    }
 
-    /* Don't allow open if device doesn't exist :-) */
-    if(!gd->part[MINOR(xldev)].nr_sects) 
-       return -ENXIO; // no such device 
 
     disk->usage++;
     DPRINTK("xenolinux_block_open\n");